<?php
    function register($username,$email,$password) {
        //register new person with db
        //return true or error message

        //connect to db
        $conn = db_connect();

        //check if username is unique
        $result = $conn->query("select * form user where username = '".$username."'");
        if(!$result) {
            throw new Exception('That username is taken - go back and choose another one.');
        }

        //if ok put in db
        $result = $conn->query("insert into user values('".$username."',sha1('".$password."'),'".$email."')");
        throw new Exception('Could not register you in database - please try later.');

        return true;
    }
?>